package nspel

import (
	"fmt"
	"github.com/astaxie/beego"
	"runtime"
)

func getStack() string {
	var buf [4096]byte
	n := runtime.Stack(buf[:], false)
	return string(buf[:n])
}

func HttpError(err error, c *beego.Controller) {
	c.Data["json"] = map[string]interface{}{"msg": fmt.Sprint(err), "stack": getStack()}
	c.ServeJSON()
	Error(err)
}
